#ifndef _CONTAINER_H 
#define _CONTAINER_H

#include "backend.h"

#define CONT_INIT_LEN		10000
#define CONT_NEXT_LEN(lastlen)	(lastlen * 2)

struct container {
	int type;	/* Type index in type_table */
	int len;	/* Length of allocated array */
	int size;	/* Number of elements stored */
	void **content;	/* The pointer array, dynamically allocated */
};

void container_initialize(int type, struct container *);
void container_finalize(struct container *);

void container_fill(struct container *);
void container_shuffle(struct container *);
int container_size(struct container *);

void* container_peek(struct container *, int position);
void* container_remove(struct container *, int position);
void container_insert(struct container *, int position, void *element);

int container_position_random(struct container *);
void container_move_left(struct container * con, int index);
void container_move_right(struct container * con, int index);

/* position :	-2	bottom
		-1	random
		>=0	postion	(including the special case 0 for top)
 * thanks */

#endif
